# 第一二种乘法表
# i是行数，k是列数
# while 循环
i=1
while i<=9:
    k=1
    while k<=i:
        print('{}*{}={:<4}'.format(i,k,i*k),end='  ')
        k=k+1
    print('')
    i=i+1
print('='*100)

i=9
while i>=1:
    k=1
    while k<=i:
        print('{}*{}={:<4}'.format(i,k,i*k),end='  ')
        k=k+1
    print('')
    i=i-1
print('='*100)
print('='*100)
print('='*100)

# for in循环
for i in range(1,10):
    for k in range(1,i+1):
        print('{}*{}={:<4}'.format(i,k,i*k),end='  ')
    print('')
print('='*100)

for i in range(9,0,-1):
    for k in range(1,i+1):
        print('{}*{}={:<4}'.format(i,k,i*k),end='  ')
    print('')
print('='*100)
print('='*100)
print('='*100)

#注意：为了使格式化输出，使用占位

# 第三四种乘法表
# i是行，k是列
# while循环
i=1
while i<10:
    k=9
    while k>0:
        if k>i:
            print('{:<8}'.format(' '), end='')
        else:
            print('{}*{}={:<4}'.format(k, i, k*i),end='')
        k = k - 1
    print('')
    i = i + 1

print('='*100)

i=9
while i>0:
    k=9
    while k>0:
        if k>i:
            print('{:<8}'.format(' '), end='')
        else:
            print('{}*{}={:<4}'.format(k, i, k*i),end='')
        k = k - 1
    print('')
    i = i - 1

print('='*100)
print('='*100)
print('='*100)

# for in循环
for i in range(1,10):
    for k in range(9,0,-1):
        if k>i:
            print('{:<8}'.format(' '), end='')
        else:
            print('{}*{}={:<4}'.format(k, i, k*i),end='')
    print('')

print('='*100)

for i in range(9,0,-1):
    for k in range(9,0,-1):
        if k>i:
            print('{:<8}'.format(' '), end='')
        else:
            print('{}*{}={:<4}'.format(k, i, k*i),end='')
    print('')
print('='*100)
print('='*100)
print('='*100)